<template>
    <div>
        <Row type="flex" justify="center" style="padding-top:150px;">
            <Form ref="formInline" :model="form" :rules="ruleInline">
              <FormItem prop="user">
                  <Input type="text" v-model="form.account" placeholder="Username">
                      <Icon type="ios-person-outline" slot="prepend"></Icon>
                  </Input>
              </FormItem>
              <FormItem prop="password">
                  <Input type="password" v-model="form.password" placeholder="Password">
                      <Icon type="ios-lock-outline" slot="prepend"></Icon>
                  </Input>
              </FormItem>
              <FormItem>
                  <Button type="primary" @click="onPost">Signin-Post</Button>
              </FormItem>
              <FormItem>
                  <Button type="primary" @click="onGet">Signin-Get</Button>
              </FormItem>
          </Form>
        </Row>
    </div>
</template>

<script>
export default {
  name: 'login',
  data () {
    return {
      form: {
        account: 'admin',
        password: '123456'
      }
    }
  },
  methods: {
    onGet () {
      this.$router.push({path: '/home'})
    },
    onPost () {
      this.$axios.post('/adminapi/helloservice', {
        account: this.form.account,
        password: this.form.password
      }).then((res) => {
        if (res.code === 0) {
          this.$message.success('登录成功')
          this.$router.push({path: '/home'})
        } else {
          this.$message.success('用户名或密码错误')
        }
      })
    }
  }
}
</script>
